/**
 * @file state.h
 * @author zybz
 * @brief
 * @version 0.1
 * @date 2022-03-25
 *
 * @copyright Copyright (c) 2022
 *
 */

#ifndef __STATE_H__
#define __STATE_H__

/* Includes ------------------------------------------------------------------*/
#include <stdbool.h>
#include "main.h"
#include "stm32f4xx_hal.h"
#include "usart.h"
#include "utils.h"
/* USER CODE BEGIN Private defines */
// 定义颜色
#define NONE 0
#define BLUE 1
#define RED 2
#define YELLOW 3
#define BROWN 4
#define GREEN 5
#define PRUPLE 6
#define BUCKET 7
#define MAGENTA 8
#define BLACK 9
// 定义方向
#define STRAIGHT 0   //笔直前进
#define LEFT 1       //调整方向，朝向左边斜着走
#define RIGHT 2      //调整方向，朝向右边斜着走
#define LEFT_TURN 3  // 左转 90
#define RIGHT_TURN 4 // 右转 90
// DMA 接收
#define HEADER1 UART3_TaskBuffer[0]
#define HEADER2 UART3_TaskBuffer[1]
#define COLOR UART3_TaskBuffer[2]
#define DIRECTION UART3_TaskBuffer[3]
#define ANGLE UART3_TaskBuffer[4]
#define OPEN UART3_TaskBuffer[5]
#define BALL UART3_TaskBuffer[6]
#define END UART3_TaskBuffer[7]
typedef enum
{
    state_debug,
    state_1_begin,
    state_recognize_ball,
    state_2_user1,
    state_3_yellow_climb,
    state_4_blue_bridge,
    state_5_magenta_downstair,
    state_6_black_obstacle, // 七个状态流转
    state_7_user2,
} STATE;

extern bool IsEnable;    //是否调用过Servo_Sync_Torque使能舵机了
extern STATE state; // 状态机状态
extern PID_s TurnPID;
extern int count_yellow;
/* 状态切换&&执行 */
void state_trans(STATE st);
void state_machine_exe(void);
/* 动作函数 */
void action_walk(void);      //走路步态
void action_upstair(void);     //爬楼步态
void action_stop(void);      //停止步态
void action_downstair(void);      //下楼步态
void action_open(void);      //开箱动作
void action_balance(void);  //平衡步态

void adjust_direction(void); // 直线调整
void adjust_turn(void);      // 转向调整
void clear_turn(void);       // 复位转弯的倾斜步态
/* USER CODE END Prototypes */

#endif

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
